/***************************************************/
/*					asm.s by doom119			   */
/* 						April, 2010				   */
/***************************************************/
.global divide_error, debug, nmi, breakpoint, overflow, bounds_check
.global invalid_opcode, double_fault
.global coprocessor_segment_overrun, invalid_tss, segment_not_present
.global stack_segment, general_protection
no_error_code:
	xchgl %eax, (%esp)
	pushl %ebx
	pushl %ecx
	pushl %edx
	pushl %edi
	pushl %esi
	pushl %ebp
	push %ds
	push %es
	push %fs
	pushl $0
	lea 44(%esp), %edx
	pushl %edx
	movl $0x10, %ebx
	mov %bx, %ds
	mov %bx, %es
	mov %bx, %fs
	call *%eax
	addl $8, %esp
	pop %fs
	pop %es
	pop %ds
	pop %ebp
	pop %esi
	pop %edi
	pop %edx
	pop %ecx
	pop %ebx
	pop %eax
	iret

divide_error:
	pushl $do_divide_error
	jmp no_error_code

debug:
	pushl $do_debug
	jmp no_error_code

nmi:
	pushl $do_nmi
	jmp no_error_code

breakpoint:
	pushl $do_breakpoint
	jmp no_error_code

overflow:
	pushl $do_overflow
	jmp no_error_code

bounds_check:
	pushl $do_bounds_check
	jmp no_error_code

invalid_opcode:
	pushl $do_invalid_opcode
	jmp no_error_code

coprocessor_segment_overrun:
	pushl $do_coprocessor_segment_overrun
	jmp no_error_code

error_code:
	xchgl %eax, (%esp)
	xchgl %ebx, 4(%esp)
	pushl %ecx
	pushl %edx
	pushl %edi
	pushl %esi
	pushl %ebp
	push %ds
	push %es
	push %fs
	pushl %ebx
	lea 44(%esp), %edx
	pushl %edx
	movl $0x10, %ebx
	mov %bx, %ds
	mov %bx, %es
	mov %bx, %fs
	call *%eax
	addl $8, %esp
	pop %fs
	pop %es
	pop %ds
	popl %ebp
	popl %esi
	popl %edi
	popl %edx
	popl %ecx
	popl %ebx
	popl %eax
	iret
	
double_fault:
	pushl $do_double_fault
	jmp error_code

invalid_tss:
	pushl $do_invalid_tss
	jmp error_code

segment_not_present:
	pushl $do_segment_not_present
	jmp error_code

stack_segment:
	pushl $stack_segment
	jmp error_code

general_protection:
	pushl $do_general_protection
	jmp error_code
